Skip to content

csnode: forward sync paces its requests to responders with an anti-duplicate log (order 35) - #136

Merged
EnzinoBB merged 7 commits into
masterfrom
fix/forward-sync-order35
Oct 31, 2026
Merged

EnzinoBB merged 7 commits into
masterfrom
fix/forward-sync-order35

Conversation

@EnzinoBB

Copy link
Copy Markdown
Collaborator

Changes forward sync: to be reviewed before merging. Not consensus-relevant: no block, hash, signature or round rule changes. Only which neighbour a sync request goes to, and when, changes, and only toward responders that send SyncroMsg.

The problem

A responder with special order 35 active keeps an anti-duplicate log of requests (Node::checkSynchroRequestsLog).

  • It refuses a request whose last sequence is not above the last one logged for the same requester while that entry lives (5 s after its reply).
  • It refuses such requests for ever after it accepted a request (AwaitAnswer) and then had nothing to send.

A node syncing from block 0 has not applied order 35 yet (Consensus::syncroChangeRound is unset), so:

  • Node::getSyncroMessage dropped the responders' SyncroMsg;
  • PoolSynchronizer kept no request log.

The result: it asked a full peer for blocks 1..100 right after 301..400, was refused every time, and never learnt it. Seen once in pruned-peers-join, run 41020112883: the joiner had 600 blocks cached and never got blocks 1..100 in 75 minutes, while only 2 of 7 peers were full. It is intermittent; it passed on master and other runs.

Change

  • Node::getSyncroMessage passes every SyncroMsg to the synchronizer, whatever this node knows of order 35. A responder sends them only when its own order 35 is active.
  • cs::SyncroPacing (new, csnode/syncropacing.hpp):
    • a peer that sent a SyncroMsg is active;
    • a request to an active peer ending at or below its live entry (5 s after the reply, 6 s here) is not sent, and the range goes to the next neighbour;
    • the same for a request below an AwaitAnswer-then-NoSuchBlocks entry, which lives for ever;
    • a DuplicatedRequest renews the entry;
    • a peer that never sent a SyncroMsg is asked as before.
  • PoolSynchronizer:
    • keeps its request log for active peers even before order 35 applies here (synchroLogFor);
    • asks SyncroPacing before each request;
    • logs once per peer SYNC: <peer> keeps an anti-duplicate log of requests (special order 35): requests to it are paced.

Where nothing changes: no responder sends SyncroMsg while order 35 is not issued, so forward sync is unchanged there. Whether mainnet has issued it is unknown (see the backward sync design).

Tests

  • Unit, tests/csnode/syncropacing_tests.cpp:
    • a peer without SyncroMsg is not paced;
    • a lower request waits for the entry, a higher one does not;
    • a lower request does not replace the entry;
    • NoSuchBlocks after AwaitAnswer lasts for ever, a plain NoSuchBlocks does not;
    • peers are independent.
  • robustness.yml, new row pruned-peers-join-official: valid with node_alt_ref=official. NODES=8; the even nodes are official full responders with order 35 serving the low blocks; the joiner, n9, runs this build.
  • Runs: pruned-peers-join three times, pruned-peers-join-official in a normal run and with node_alt_ref=official, plus the Linux and Windows/macOS builds. The runs are posted in the comments.

🤖 Generated with Claude Code

EnzinoBB and others added 3 commits October 30, 2026 15:32
…plicate log (order 35)

A responder with special order 35 active refuses a request whose last
sequence is not above the last one it logged for the same requester, while
that entry lives (5 s after its reply), and for ever after it accepted a
request (AwaitAnswer) and had nothing to send. A node syncing from block 0
has not applied order 35 yet: Node::getSyncroMessage dropped the responders'
SyncroMsg, and the synchronizer kept no request log, so it went on asking a
full peer for blocks 1..100 right after blocks 301..400, refused every time
(pruned-peers-join: a joiner that never got blocks 1..100 in 75 minutes,
seen once).

- Node::getSyncroMessage passes every SyncroMsg to the synchronizer, whatever
  this node knows of order 35 (a responder sends them only when its order 35
  is active).
- cs::SyncroPacing (new): a peer that sent a SyncroMsg is active; a request
  to it whose last sequence is at or below its live entry, or below an
  AwaitAnswer-then-NoSuchBlocks entry, is not sent: the range goes to the
  next neighbour. A peer that never sent one is asked as before.
- PoolSynchronizer keeps its request log for active peers even before order
  35 applies here (synchroLogFor); logs once per peer when it becomes
  active.

Nothing changes where no responder sends SyncroMsg (order 35 not issued).

Tests: syncropacing_tests.cpp. robustness.yml: pruned-peers-join-official
(valid with node_alt_ref=official: official full responders serve the low
blocks).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…took it)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@EnzinoBB

Copy link
Copy Markdown
Collaborator Author

CI: Linux run 41072773657 green; Windows/macOS run 41072773437: Windows green, macOS cancelled for lack of a runner, re-run in progress. Robustness: pruned-peers-join green three times (runs 41072763928, 41072782217, 41072800045), pruned-peers-join-official green in a normal run (41072763928) and with node_alt_ref=official (41072818530: the even nodes are official 4.2.532 responders with order 35). Not merged: it changes forward sync and waits for review.

@EnzinoBB

Copy link
Copy Markdown
Collaborator Author

macOS re-run of run 41072773437: green. All CI green on #136; not merged, waiting for review (it changes forward sync).

EnzinoBB and others added 2 commits October 30, 2026 22:28
Node::getSyncroMessage: the bound check first, then the backfill and the
forward sync both read every SyncroMsg, whatever this node knows of order 35.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- M2: the backfill and the forward sync both read every SyncroMsg now. An
  answer counts for the forward sync only while a forward request to that
  peer is in flight (SyncroPacing::inFlight); any other one marks the peer
  active and changes neither the pacing nor synchroLog_.
- M3: every forward request is recorded, also to a peer that has not sent a
  SyncroMsg yet, so that AwaitAnswer then NoSuchBlocks on the first request
  counts. A refusal the responder does not log (NoSuchBlocks without
  AwaitAnswer, DuplicatedRequest, IncorrectRequest) leaves the entry it held.
- L1: a neighbour removed is forgotten.
- L2: "for ever" (NoSuchBlocks after AwaitAnswer) lasts an hour here.
- L4: an AwaitAnswer entry of synchroLog_ (order 35 known) expires after
  30 s, as a forward request in flight does, so that a peer whose reply was
  lost is asked again.

Tests: a request sent before the peer's first SyncroMsg; a DuplicatedRequest
with no request recorded; answers to the backfill leave the forward state
alone; a request without an answer expires; the hour of "for ever".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@EnzinoBB

Copy link
Copy Markdown
Collaborator Author

Review fixes (Fable): master merged in (bb6b3a4: Node::getSyncroMessage bound-checks first, then the backfill and the forward sync both read every SyncroMsg), M2/M3/L1/L2/L4 in b95abcd (an answer counts for the forward sync only while a forward request to that peer is in flight; every forward request recorded; refusals the responder does not log leave its entry; neighbour removal forgets; 'for ever' = 1 h; AwaitAnswer entries of synchroLog_ expire after 30 s). L3 not done (optional). L5 (getRequiredBlocks re-requesting a contiguous cache) left as a follow-up.
CI on b95abcd: Linux 41131635000 green; Windows/macOS 41131634535 green after a re-run (macOS failed once on PollUntil.LastAttemptAtTheDeadline: 2 calls in 250 ms on a slow runner, a timing-sensitive test from #126 unrelated to this change); robustness 41131641380, 41131655601 (pruned-peers-join, pruned-peers-join-official, backfill-join, backfill-order35, snapshot-p2p-join: each run executed the whole list) and 41131670673 with node_alt_ref=official: all green, so pruned-peers-join three times, pruned-peers-join-official twice plain and once against official responders.

@EnzinoBB
EnzinoBB merged commit e0d2d31 into master Oct 31, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant